home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Games / MAME / src / drivers / lasso.c < prev    next >
C/C++ Source or Header  |  2000-05-04  |  9KB  |  349 lines

  1. /*    Lasso
  2. **    (C)1982 SNK
  3. **
  4. **    input port issues:
  5. **    - fire button auto-repeats on high score entry screen (real behavior?)
  6. **
  7. **    unknown CPU speeds (effects game timing)
  8. */
  9.  
  10. #include "driver.h"
  11. #include "vidhrdw/generic.h"
  12. #include "cpu/z80/z80.h"
  13.  
  14. WRITE_HANDLER( lasso_videoram_w );
  15. WRITE_HANDLER( lasso_backcolor_w );
  16. WRITE_HANDLER( lasso_cocktail_w );
  17. void lasso_vh_convert_color_prom( UINT8 *palette, UINT16 *colortable, const UINT8 *color_prom );
  18. void lasso_vh_screenrefresh( struct osd_bitmap *bitmap, int fullrefresh );
  19. int lasso_vh_start( void );
  20.  
  21. extern unsigned char *lasso_vram; /* 0x2000 bytes for a 256x256x1 bitmap */
  22.  
  23.  
  24.  
  25. int lasso_interrupt( void )
  26. {
  27.     if (cpu_getiloops() == 0)
  28.         return interrupt();
  29.     else
  30.         return nmi_interrupt(); // coin input
  31. }
  32.  
  33.  
  34. static UINT8 *shareram;
  35.  
  36. static READ_HANDLER( shareram_r )
  37. {
  38.     return shareram[offset];
  39. }
  40.  
  41. static WRITE_HANDLER( shareram_w )
  42. {
  43.     shareram[offset] = data;
  44. }
  45.  
  46. static WRITE_HANDLER( lasso_sound_command_w )
  47. {
  48.     soundlatch_w(offset,data);
  49.     cpu_cause_interrupt( 2, Z80_IRQ_INT ); /* ? */
  50. }
  51.  
  52. static READ_HANDLER( sound_status_r )
  53. {
  54.     /*    0x01: chip#0 ready; 0x02: chip#1 ready */
  55.     return 0x03;
  56. }
  57.  
  58. static int lasso_chip_data;
  59.  
  60. static WRITE_HANDLER( sound_data_w )
  61. {
  62.     lasso_chip_data =
  63.             ((data & 0x80) >> 7) |
  64.             ((data & 0x40) >> 5) |
  65.             ((data & 0x20) >> 3) |
  66.             ((data & 0x10) >> 1) |
  67.             ((data & 0x08) << 1) |
  68.             ((data & 0x04) << 3) |
  69.             ((data & 0x02) << 5) |
  70.             ((data & 0x01) << 7);
  71. }
  72.  
  73. static WRITE_HANDLER( sound_select_w )
  74. {
  75.     if (~data & 0x01)    /* chip #0 */
  76.         SN76496_0_w(0,lasso_chip_data);
  77.     if (~data & 0x02)    /* chip #1 */
  78.         SN76496_1_w(0,lasso_chip_data);
  79. }
  80.  
  81.  
  82.  
  83. INPUT_PORTS_START( lasso )
  84.     PORT_START /* 1804 */
  85.     PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT | IPF_4WAY )
  86.     PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT  | IPF_4WAY )
  87.     PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP    | IPF_4WAY )
  88.     PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN  | IPF_4WAY )
  89.     PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_BUTTON1 ) /* lasso */
  90.     PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_BUTTON2 ) /* shoot */
  91.     PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_UNUSED )
  92.     PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_UNUSED )
  93.  
  94.     PORT_START /* 1805 */
  95.     PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT | IPF_COCKTAIL | IPF_4WAY )
  96.     PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT  | IPF_COCKTAIL | IPF_4WAY )
  97.     PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP    | IPF_COCKTAIL | IPF_4WAY )
  98.     PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN  | IPF_COCKTAIL | IPF_4WAY )
  99.     PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_BUTTON1 | IPF_COCKTAIL )
  100.     PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_BUTTON2    | IPF_COCKTAIL )
  101.     PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_UNUSED )
  102.     PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_UNUSED )
  103.  
  104.     PORT_START /* 1806 */
  105.     PORT_DIPNAME( 0x01, 0x01, DEF_STR( Cabinet ) )
  106.     PORT_DIPSETTING(    0x01, DEF_STR( Upright ) )
  107.     PORT_DIPSETTING(    0x00, DEF_STR( Cocktail ) )
  108.     PORT_DIPNAME( 0x0e, 0x0e, DEF_STR( Coinage ) )
  109.     PORT_DIPSETTING(    0x02, DEF_STR( 2C_1C ) )
  110.     PORT_DIPSETTING(    0x0e, DEF_STR( 1C_1C ) )
  111.     PORT_DIPSETTING(    0x08, DEF_STR( 1C_2C ) )
  112.     PORT_DIPSETTING(    0x04, DEF_STR( 1C_3C ) )
  113.     PORT_DIPSETTING(    0x0c, DEF_STR( 1C_6C ) )
  114. //    PORT_DIPSETTING(    0x06, DEF_STR( 1C_1C ) )
  115. //    PORT_DIPSETTING(    0x00, DEF_STR( 1C_1C ) )
  116. //    PORT_DIPSETTING(    0x0a, DEF_STR( 1C_1C ) )
  117.     PORT_DIPNAME( 0x30, 0x30, DEF_STR( Lives ) )
  118.     PORT_DIPSETTING(    0x30, "3" )
  119.     PORT_DIPSETTING(    0x10, "4" )
  120.     PORT_DIPSETTING(    0x20, "5" )
  121. //    PORT_DIPSETTING(    0x00, "3" )
  122.     PORT_DIPNAME( 0x40, 0x40, DEF_STR( Unknown ) )
  123.     PORT_DIPSETTING(    0x40, DEF_STR( Off ) )
  124.     PORT_DIPSETTING(    0x00, DEF_STR( On ) )
  125.     PORT_DIPNAME( 0x80, 0x80, "Show Instructions" )
  126.     PORT_DIPSETTING(    0x00, DEF_STR( No ) )
  127.     PORT_DIPSETTING(    0x80, DEF_STR( Yes ) )
  128.  
  129.     PORT_START /* 1807 */
  130.     PORT_BIT( 0x0f, IP_ACTIVE_HIGH, IPT_UNKNOWN )
  131.     PORT_BIT_IMPULSE( 0x10, IP_ACTIVE_LOW, IPT_COIN2, 1 )
  132.     PORT_BIT_IMPULSE( 0x20, IP_ACTIVE_LOW, IPT_COIN1, 1 )
  133.     PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_START2 )
  134.     PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_START1 )
  135. INPUT_PORTS_END
  136.  
  137.  
  138.  
  139.  
  140. /* 17f0 on CPU1 maps to 07f0 on CPU2 */
  141. static struct MemoryReadAddress readmem[] =
  142. {
  143.     { 0x0000, 0x03ff, MRA_RAM }, /* work ram */
  144.     { 0x0400, 0x0bff, MRA_RAM }, /* videoram */
  145.     { 0x0c00, 0x0c7f, MRA_RAM }, /* spriteram */
  146.     { 0x1000, 0x17ff, shareram_r },
  147.     { 0x1804, 0x1804, input_port_0_r },
  148.     { 0x1805, 0x1805, input_port_1_r },
  149.     { 0x1806, 0x1806, input_port_2_r },
  150.     { 0x1807, 0x1807, input_port_3_r },
  151.     { 0x8000, 0xffff, MRA_ROM },
  152.     { -1 }
  153. };
  154.  
  155. static struct MemoryWriteAddress writemem[] =
  156. {
  157.     { 0x0000, 0x03ff, MWA_RAM },
  158.     { 0x0400, 0x0bff, lasso_videoram_w, &videoram },
  159.     { 0x0c00, 0x0c7f, MWA_RAM, &spriteram },
  160.     { 0x1000, 0x17ff, shareram_w },
  161.     { 0x1800, 0x1800, lasso_sound_command_w },
  162.     { 0x1801, 0x1801, lasso_backcolor_w },
  163.     { 0x1802, 0x1802, lasso_cocktail_w },
  164.     { 0x1806, 0x1806, MWA_NOP }, /* spurious write */
  165.     { 0x8000, 0xffff, MWA_ROM },
  166.     { -1 }
  167. };
  168.  
  169. static struct MemoryReadAddress readmem_coprocessor[] =
  170. {
  171.     { 0x0000, 0x07ff, MRA_RAM },    /* shared RAM */
  172.     { 0x2000, 0x3fff, MRA_RAM },
  173.     { 0x8000, 0x8fff, MRA_ROM },
  174.     { 0xf000, 0xffff, MRA_ROM },
  175.     { -1 }
  176. };
  177.  
  178. static struct MemoryWriteAddress writemem_coprocessor[] =
  179. {
  180.     { 0x0000, 0x07ff, MWA_RAM, &shareram },    /* code is executed from here */
  181.     { 0x2000, 0x3fff, MWA_RAM, &lasso_vram },
  182.     { 0x8000, 0x8fff, MWA_ROM },
  183.     { 0xf000, 0xffff, MWA_ROM },
  184.     { -1 }
  185. };
  186.  
  187. static struct MemoryReadAddress readmem_sound[] =
  188. {
  189.     { 0x0000, 0x01ff, MRA_RAM },
  190.     { 0x5000, 0x7fff, MRA_ROM },
  191.     { 0xb004, 0xb004, sound_status_r },
  192.     { 0xb005, 0xb005, soundlatch_r },
  193.     { 0xf000, 0xffff, MRA_ROM },
  194.     { -1 }
  195. };
  196.  
  197. static struct MemoryWriteAddress writemem_sound[] =
  198. {
  199.     { 0x0000, 0x01ff, MWA_RAM },
  200.     { 0x5000, 0x7fff, MWA_ROM },
  201.     { 0xb000, 0xb000, sound_data_w },
  202.     { 0xb001, 0xb001, sound_select_w },
  203.     { 0xf000, 0xffff, MWA_ROM },
  204.     { -1 }
  205. };
  206.  
  207.  
  208.  
  209. static struct GfxLayout tile_layout =
  210. {
  211.     8,8,
  212.     0x100,
  213.     2,
  214.     { 0, 0x2000*8 },
  215.     { 0,1,2,3,4,5,6,7 },
  216.     { 0*8,1*8,2*8,3*8,4*8,5*8,6*8,7*8 },
  217.     8*8
  218. };
  219.  
  220. static struct GfxLayout sprite_layout =
  221. {
  222.     16,16,
  223.     0x40,
  224.     2,
  225.     { 0, 0x2000*8 },
  226.     {
  227.         0,1,2,3,4,5,6,7,
  228.         64+0,64+1,64+2,64+3,64+4,64+5,64+6,64+7
  229.     },
  230.     {
  231.         0*8,1*8,2*8,3*8,4*8,5*8,6*8,7*8,
  232.         128+0*8,128+1*8,128+2*8,128+3*8,128+4*8,128+5*8,128+6*8,128+7*8
  233.     },
  234.     32*8
  235. };
  236.  
  237. static struct GfxDecodeInfo gfxdecodeinfo[] =
  238. {
  239.     { REGION_GFX1, 0x0000, &tile_layout,   0, 0x10 },
  240.     { REGION_GFX1, 0x1000, &tile_layout,   0, 0x10 },
  241.     { REGION_GFX1, 0x0800, &sprite_layout, 0, 0x10 },
  242.     { REGION_GFX1, 0x1800, &sprite_layout, 0, 0x10 },
  243.     { -1 }
  244. };
  245.  
  246.  
  247.  
  248. static struct SN76496interface sn76496_interface =
  249. {
  250.     2,    /* 2 chips */
  251.     { 2000000, 2000000 },    /* ? MHz */
  252.     { 100, 100 }
  253. };
  254.  
  255.  
  256.  
  257. static struct MachineDriver machine_driver_lasso =
  258. {
  259.     {
  260.         {
  261.             CPU_M6502,
  262.             2000000,    /* 2 MHz (?) */
  263.             readmem,writemem,0,0,
  264.             lasso_interrupt,2,
  265.         },
  266.         {
  267.             CPU_M6502,
  268.             2000000,    /* 2 MHz (?) */
  269.             readmem_coprocessor,writemem_coprocessor,0,0,
  270.             ignore_interrupt,1,
  271.         },
  272.         {
  273.             CPU_M6502 | CPU_AUDIO_CPU,
  274.             600000,    /* ?? (controls music tempo) */
  275.             readmem_sound,writemem_sound,0,0,
  276.             ignore_interrupt,1,
  277.         },
  278.     },
  279.     60, DEFAULT_REAL_60HZ_VBLANK_DURATION,
  280.     100, /* CPU slices */
  281.     0, /* init machine */
  282.  
  283.     /* video hardware */
  284.     32*8, 32*8, { 0, 255, 16, 255-16 },
  285.     gfxdecodeinfo,
  286.     0x40,0x40,
  287.     lasso_vh_convert_color_prom,
  288.  
  289.     VIDEO_TYPE_RASTER | VIDEO_MODIFIES_PALETTE,
  290.     0,
  291.     lasso_vh_start,
  292.     0,
  293.     lasso_vh_screenrefresh,
  294.  
  295.     /* sound hardware */
  296.     0,0,0,0,
  297.     {
  298.         {
  299.             SOUND_SN76496,
  300.             &sn76496_interface
  301.         }
  302.     }
  303. };
  304.  
  305. /*
  306. USES THREE 6502 CPUS
  307.  
  308. CHIP #  POSITION  TYPE
  309. -----------------------
  310. WMA     IC19      2732   DAUGHTER BD    sound cpu
  311. WMB     IC18       "      "                sound data
  312. WMC     IC17       "      "                sound data
  313. WM5     IC45       "     CONN BD        bitmap coprocessor
  314. 82S123  IC69              "
  315. 82S123  IC70              "
  316. WM4     IC22      2764   BOTTOM BD        main cpu
  317. WM3     IC21       "      "                main cpu
  318. WM2     IC66       "      "                graphics
  319. WM1     IC65       "      "                graphics
  320. */
  321. ROM_START( lasso )
  322.     ROM_REGION( 0x10000, REGION_CPU1 ) /* 6502 code (main cpu) */
  323.     ROM_LOAD( "wm3",       0x8000, 0x2000, 0xf93addd6 )
  324.     ROM_RELOAD(            0xc000, 0x2000)
  325.     ROM_LOAD( "wm4",       0xe000, 0x2000, 0x77719859 )
  326.     ROM_RELOAD(            0xa000, 0x2000)
  327.  
  328.     ROM_REGION( 0x10000, REGION_CPU2 ) /* 6502 code (lasso image blitter) */
  329.     ROM_LOAD( "wm5",       0xf000, 0x1000, 0x7dc3ff07 )
  330.     ROM_RELOAD(            0x8000, 0x1000)
  331.  
  332.     ROM_REGION( 0x10000, REGION_CPU3 ) /* 6502 code (sound) */
  333.     ROM_LOAD( "wmc",       0x5000, 0x1000, 0x8b4eb242 )
  334.     ROM_LOAD( "wmb",       0x6000, 0x1000, 0x4658bcb9 )
  335.     ROM_LOAD( "wma",       0x7000, 0x1000, 0x2e7de3e9 )
  336.     ROM_RELOAD(            0xf000, 0x1000 )
  337.  
  338.     ROM_REGION( 0x4000, REGION_GFX1 | REGIONFLAG_DISPOSE )
  339.     ROM_LOAD( "wm1",       0x0000, 0x2000, 0x7db77256 )
  340.     ROM_LOAD( "wm2",       0x2000, 0x2000, 0x9e7d0b6f )
  341.  
  342.     ROM_REGION( 0x40, REGION_PROMS )
  343.     ROM_LOAD( "82s123.69", 0x0000, 0x0020, 0x1eabb04d )
  344.     ROM_LOAD( "82s123.70", 0x0020, 0x0020, 0x09060f8c )
  345. ROM_END
  346.  
  347.  
  348. GAME( 1982, lasso, 0, lasso, lasso, 0, ROT90, "SNK", "Lasso" )
  349.